﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using FinPlusCommon;

namespace FinPlusStructure
{
    public class FinPlusStructure
    {
        //adaptors
        public static IFunction QuoteAdaptor(string QuoteSource, IFunction ReceiveAction, IFunction PublishAction)
        {
            var func = new Function("QuoteSource");
            func["QuoteSource"] = QuoteSource;
            func["ReceiveAction"] = ReceiveAction;
            func["PublishAction"] = PublishAction;
            return func;
        }

        public static IFunction TradeAdaptor(string InstrumentType, IFunction ReceiveQuoteAction, IFunction ParseTradeAction, IFunction ResponseAction)
        {
            var func = new Function("TradeAdaptor");
            func["InstrumentType"] = InstrumentType;
            func["ReceiveQuoteAction"] = ReceiveQuoteAction;
            func["ParseTradeAction"] = ParseTradeAction;
            func["ResponseAction"] = ResponseAction;
            return func;
        }

        //market making
        public static IFunction Index(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Index");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func;
        }

        public static IFunction Rate(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Rate");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func; 
        }

        public static IFunction Price(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Price");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func;
        }

        public static IFunction Spread(string Market, string Instrument, string BuySell, double Level, string Source, int Date)
        {
            var func = new Function("Spread");
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Level"] = Level;
            func["Source"] = Source;
            func["Date"] = Date;
            return func;
        }

        public static IFunction Setting(string IndexName, double Level, int Date)
        {
            var func = new Function("Setting");
            func["IndexName"] = IndexName;
            func["Level"] = Level;
            func["Date"] = Date;
            return func;
        }

        public static IFunction Quote(string QuoteRef, string Instrument, string BuySell, double Quote, double Size, string QuoteStyle, string QuoteType, string RateType, string QuoteSource, string Counterparty) 
        {
            var func = new Function("Quote");
            func["QuoteRef"] = QuoteRef;
            func["Instrument"] = Instrument;
            func["BuySell"] = BuySell;
            func["Quote"] = Quote;
            func["Size"] = Size;
            func["QuoteStyle"] = QuoteStyle;
            func["QuoteType"] = QuoteType;
            func["RateType"] = RateType;
            func["QuoteSource"] = QuoteSource;
            func["Counterparty"] = Counterparty;
            return func; 
        }

        public static IFunction QuoteInterest(string Instrument, string Book, bool IsAxe, string BuySell, double Quote, double Size, string QuoteStyle, string QuoteType, string QuoteMark, string RateType, string Trader)
        {
            var func = new Function("QuoteInterest");
            func["Instrument"] = Instrument;
            func["Book"] = Book;
            func["IsAxe"] = IsAxe;
            func["BuySell"] = BuySell;
            func["Quote"] = Quote;
            func["Size"] = Size;
            func["QuoteStyle"] = QuoteStyle;
            func["QuoteType"] = QuoteType;
            func["QuoteMark"] = QuoteMark;
            func["RateType"] = RateType;
            func["Trader"] = Trader;
            return func;
        }

        public static IFunction QuoteCancel(string QuoteRef) 
        {
            var func = new Function("QuoteCancel");
            func["QuoteRef"] = QuoteRef;
            return func;
        }

        public static IFunction QuoteExecute(string QuoteRef, double Size) 
        {
            var func = new Function("QuoteExecute");
            func["QuoteRef"] = QuoteRef;
            func["Size"] = Size;
            return func;
        }

        public static IFunction QuoteStyle(string QuoteStyle) 
        {
            var func = new Function("QuoteStyle");
            func["QuoteStyle"] = QuoteStyle;
            return func;
        }

        public static IFunction QuoteType(string QuoteType) 
        {
            var func = new Function("QuoteType");
            func["QuoteType"] = QuoteType;
            return func;
        }

        public static IFunction QuoteMark(string QuoteMark)
        {
            var func = new Function("QuoteMark");
            func["QuoteMark"] = QuoteMark;
            return func;
        }

        public static IFunction QuoteSource(string QuoteSource, string User, string Location) 
        {
            var func = new Function("QuoteSource");
            func["QuoteSource"] = QuoteSource;
            func["User"] = User;
            func["Location"] = Location;
            return func;
        }

        public static IFunction CounterpartyQuoteTier(string Counterparty, string InstrumentType, double Adjustment)
        {
            var func = new Function("QuoteTier");
            func["Counterparty"] = Counterparty;
            func["InstrumentType"] = InstrumentType;
            func["Adjustment"] = Adjustment;
            return func;
        }

        public static IFunction Instrument(string Instrument, string Ccy, string LinkedCurve, string InstrumentName, string InstrumentType, string RateType, double ChgMin, double SizeMin, double SizeMax, double ShockUnit) 
        {
            var func = new Function("Instrument");
            func["Instrument"] = Instrument;
            func["Ccy"] = Ccy;
            func["LinkedCurve"] = LinkedCurve;
            func["InstrumentName"] = InstrumentName;
            func["InstrumentType"] = InstrumentType;
            func["RateType"] = RateType;
            func["ChgMin"] = ChgMin;
            func["SizeMin"] = SizeMin;
            func["SizeMax"] = SizeMax;
            func["ShockUnit"] = ShockUnit;
            return func;
        }

        public static IFunction InstrumentSpread(string Instrument, string SpreadName, string Spread, string SpreadType, bool IsMktToMkt, double BuyAdj, double SellAdj, double Weight, string Trader)
        {
            var func = new Function("InstrumentSpread");
            func["Instrument"] = Instrument;
            func["SpreadName"] = SpreadName;
            func["Spread"] = Spread;
            func["SpreadType"] = SpreadType;
            func["Weight"] = Weight;
            func["IsMktToMkt"] = IsMktToMkt;
            func["BuyAdj"] = BuyAdj;
            func["SellAdj"] = SellAdj;
            func["Trader"] = Trader;
            return func;
        }

        public static IFunction InstrumentType(string InstrumentType)
        {
            var func = new Function("InstrumentType");
            func["InstrumentType"] = InstrumentType;
            return func;
        }

        public static IFunction RateType(string RateType)
        {
            var func = new Function("RateType");
            func["RateType"] = RateType;
            return func;
        }

        public static IFunction Ccy(string Ccy, string Name) 
        {
            var func = new Function("Ccy");
            func["Ccy"] = Ccy;
            func["Name"] = Name;
            return func;
        }

        public static IFunction BuySell(string BuySell) 
        {
            var func = new Function("BuySell");
            func["BuySell"] = BuySell;
            return func;
        }

        public static IFunction SpreadType(string SpreadType)
        {
            var func = new Function("SpreadType");
            func["SpreadType"] = SpreadType;
            return func;
        }

        public static IFunction BizConv(string BizConv)
        {
            var func = new Function("BizConv");
            func["BizConv"] = BizConv;
            return func;
        }

        public static IFunction DayCount(string DayCount)
        {
            var func = new Function("DayCount");
            func["DayCount"] = DayCount;
            return func;
        }

        public static IFunction Holidays(string Holidays)
        {
            var func = new Function("Holidays");
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction Freq(string Freq)
        {
            var func = new Function("Freq");
            func["Freq"] = Freq;
            return func;
        }

        public static IFunction PayRec(string PayRec)
        {
            var func = new Function("PayRec");
            func["PayRec"] = PayRec;
            return func;
        }

        public static IFunction CurveName(string CurveName, string CurveType)
        {
            var func = new Function("CurveName");
            func["CurveName"] = CurveName;
            func["CurveType"] = CurveType;
            return func;
        }

        public static IFunction CurveType(string CurveType)
        {
            var func = new Function("CurveName");
            func["CurveName"] = CurveType;
            return func;
        }

        //templates
        public static IFunction VanillaSwapBuild(string Instrument, string CurveName, int SettlementDays, bool EndOfMonth, string Maturity, string Index, double Spread, string FixLegFrq, string FltLegFrq, string FixLegConv, string FltLegConv, string FixLegDayCount, string FltLegDayCount, string Holidays)
        {
            var func = new Function("VanillaSwapBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["EndOfMonth"] = EndOfMonth;
            func["Maturity"] = Maturity;
            func["Index"] = Index;
            func["Spread"] = Spread;
            func["FixLegFrq"] = Index;
            func["FltLegFrq"] = Index;
            func["FixLegConv"] = Index;
            func["FltLegConv"] = Index;
            func["FixLegDayCount"] = Index;
            func["FltLegDayCount"] = Index;
            func["Holidays"] = Index;
            return func;
        }

        public static IFunction ForwardRateAgreementBuild(string Instrument, string CurveName, int SettlementDays, string Start, string Maturity, string Index, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("ForwardRateAgreementBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["Start"] = Start;
            func["Maturity"] = Maturity;
            func["Index"] = Index;
            func["DayCount"] = DayCount;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction DepositLoanBuild(string Instrument, string CurveName, int SettlementDays, string Maturity, string Index, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("DepositLoanBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["Maturity"] = Maturity;
            func["Index"] = Index;
            func["DayCount"] = DayCount;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction ZCMBuild(string Instrument, string Maturity, int SettlementDays, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("ZCMBuild");
            func["Instrument"] = Instrument;
            func["Maturity"] = Maturity;
            func["SettlementDays"] = SettlementDays;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction IRFutureBuild(string Instrument, string CurveName, int StartDate, int FutMonths, string DayCount, string BizConv, string Holidays)
        {
            var func = new Function("IRFutureBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["StartDate"] = StartDate;
            func["FutMonths"] = FutMonths;
            func["DayCount"] = DayCount;
            func["BizConv"] = BizConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction CreditDefaultSwapBuild(string Instrument, string CurveName, int SettlementDays, string Maturity, string PremFreq, string PremConv, string PayConv, string DayCount, string Holidays)
        {
            var func = new Function("CreditDefaultSwapBuild");
            func["Instrument"] = Instrument;
            func["CurveName"] = CurveName;
            func["SettlementDays"] = SettlementDays;
            func["Maturity"] = Maturity;
            func["PremFreq"] = PremFreq;
            func["PremConv"] = PremConv;
            func["PayConv"] = PayConv;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction YieldCurveBuild(string CurveName, string Ccy, int NumDepo, int NumFut, int NumFra, int NumSwap, string Index, string DayCount, string Tolerance, string Holidays)
        {
            var func = new Function("YieldCurveBuild");
            func["CurveName"] = CurveName;
            func["Ccy"] = Ccy;
            func["NumDepo"] = Ccy;
            func["NumFut"] = NumFut;
            func["NumFra"] = NumFra;
            func["NumSwap"] = NumSwap;
            func["Index"] = Index;
            func["DayCount"] = DayCount;
            func["Tolerance"] = Tolerance;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction DefaultCurveBuild(string CurveName, string Ccy, int NumSpread, string CreditName, double RecoveryRate, string DayCount, string Holidays)
        {
            var func = new Function("DefaultCurveBuild");
            func["CurveName"] = CurveName;
            func["Ccy"] = Ccy;
            func["NumSpread"] = NumSpread;
            func["CreditName"] = CreditName;
            func["RecoveryRate"] = RecoveryRate;
            func["DayCount"] = DayCount;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction BondCurveBuild(string CurveName, string Ccy, int NumZCM, int NumBond, string DayCount, double Tolerance, string Holidays)
        {
            var func = new Function("CurveName");
            func["DayCount"] = DayCount;
            func["Tolerance"] = Tolerance;
            func["Holidays"] = Holidays;
            return func;
        }

        public static IFunction IndexBuild(string IndexName, string CurveName, string IndexType, string Tenor)
        {
            var func = new Function("IndexBuild");
            func["IndexName"] = IndexName;
            func["CurveName"] = CurveName;
            func["IndexType"] = IndexType;
            func["Tenor"] = Tenor;
            return func;
        }

        //permissions
        public static IFunction Permission(string User, string Name, string ItemName, string ItemValue, bool CanRead, bool CanWrite)
        {
            var func = new Function("Permission");
            func["User"] = User;
            func["Name"] = Name;
            func["ItemName"] = ItemName;
            func["ItemValue"] = ItemValue;
            func["CanRead"] = CanRead;
            func["CanWrite"] = CanWrite;
            return func;
        }

        //info
        public static IFunction Application(string Application, string Description, string Owner)
        {
            var func = new Function("Application");
            func["Application"] = Application;
            func["Description"] = Description;
            func["Owner"] = Owner;
            return func;
        }

        //business structure
        public static IFunction Location(string Location, string Country, string Region)
        {
            var func = new Function("Location");
            func["Location"] = Location;
            func["Country"] = Country;
            func["Region"] = Region;
            return func;
        }

        public static IFunction Department(string Department, string Location)
        {
            var func = new Function("Department");
            func["Department"] = Department;
            func["Location"] = Location;
            return func;
        }

        public static IFunction Desk(string Desk, string Department)
        {
            var func = new Function("Desk");
            func["Desk"] = Desk;
            func["Department"] = Department;
            return func;
        }

        public static IFunction Book(string Book, string Desk, string Department, string Location)
        {
            var func = new Function("Book");
            func["Desk"] = Desk;
            func["Department"] = Department;
            func["Location"] = Location;
            return func;
        }

        public static IFunction User(string User, string UserName, string Desk, string Location)
        {
            var func = new Function("User");
            func["User"] = User;
            func["UserName"] = UserName;
            func["Desk"] = Desk;
            func["Location"] = Location;
            return func;
        }

        //country structure
        public static IFunction Region(string Region)
        {
            var func = new Function("Region");
            func["Region"] = Region;
            return func;
        }

        public static IFunction Country(string Country, string Region)
        {
            var func = new Function("Country");
            func["Country"] = Country;
            func["Region"] = Region;
            return func;
        }

        //company structure
        public static IFunction Counterparty(string Counterparty, string LongName, string Identifier, string DefaultCollateralCurve, string Country, string Sector, string Region, string InternalRating, string MoodysRating, string SnPRating)
        {
            var func = new Function("Counterparty");
            func["Counterparty"] = Counterparty;
            func["LongName"] = Counterparty;
            func["Identifier"] = Identifier;
            func["Country"] = Country;
            func["DefaultCollateralCurve"] = DefaultCollateralCurve;
            func["Sector"] = Sector;
            func["Region"] = Region;
            func["InternalRating"] = InternalRating;
            func["MoodysRating"] = MoodysRating;
            func["SnPRating"] = SnPRating;
            return func;
        }

        public static IFunction Sector(string Sector)
        {
            var func = new Function("Sector");
            func["Sector"] = Sector;
            return func;
        }

        public static IFunction InternalRating(string InternalRating, int Index)
        {
            var func = new Function("InternalRating");
            func["InternalRating"] = InternalRating;
            func["Index"] = Index;
            return func;
        }

        public static IFunction MoodysRating(string MoodysRating, int Index)
        {
            var func = new Function("MoodysRating");
            func["MoodysRating"] = MoodysRating;
            func["Index"] = Index;
            return func;
        }

        public static IFunction SnPRating(string SnPRating, int Index)
        {
            var func = new Function("SnPRating");
            func["SnPRating"] = SnPRating;
            func["Index"] = Index;
            return func;
        }

        //admin
        public static IFunction FunctionMap(string Group, string Name)
        {
            var func = new Function("FunctionMap");
            func["Group"] = Group;
            func["Name"] = Name;
            return func;
        }
    }
}
